import { AfterViewInit, Component, OnInit, Renderer2 } from '@angular/core';
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import { ApesMessageService } from '@shared/apes/message';
import { ApiService } from '@core/services/http/api.service';
import { isNotNil } from '@shared/apes/core/util/check';

export type  panelVisible = 'admin' | 'current';

@Component({
  selector: 'e-commerce',
  templateUrl: './e-commerce.component.html',
})

export class ECommerceComponent implements OnInit, AfterViewInit {


  params: any;

  ctx = { model: {} };

  curCanvasData: any = {}; // 当前展示看板

  panelVisible: panelVisible = 'current'; // 面板展示

  // 按钮相关
  buttonBar = [
    { hide: true, style: 'default', label: '当前面板', id: 'action_current' },
    { hide: true, style: 'default', label: '管理面板', id: 'action_admin' },
  ];

  constructor(private renderer: Renderer2,
              private msg: ApesMessageService,
              private apiService: ApiService) {
  }

  ngOnInit() {

  }

  ngAfterViewInit() {

  }

  // 头部按钮层
  onEvent(data: any) {
    if (data instanceof MouseEvent) return;
    if (data) {
      if (data.id === 'action_current') {
        this.showPanel('current');
      } else if (data.id === 'action_admin') {
        this.showPanel('admin');
        // } else if (data.id === 'action_add') {
        //   this.msg.error('功能暂未开放');
      }
    }
  }

  show($event) {
    console.log($event);
    this.panelVisible = 'current';
    this.curCanvasData = $event;
  }

  // 打开管理面板
  showPanel(name: panelVisible) {
    this.panelVisible = name;
  }

  // 关闭管理面板
  // closePanel() {
  //   this.panelVisible = false;
  // }

  /***
   * TODO
   * 1.小程序的弹出查询，需要提供每个小程序对应的快照（待定）
   * 2.默认取看板逻辑
   * 3.特殊组件提供自定义方法用于提供私人定制化服务以及预设小程序设定
   * 4.权限体系的内嵌
   *    - 小程序的权限
   *    - 看板的权限
   * 5. 提供预设看板以及默认看板的功能
   * 6. 看板切换
   *
   */

}
